package com.hissagetest;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.view.ViewGroup;
import android.view.Window;
import android.view.View.OnClickListener;
import android.view.ViewGroup.LayoutParams;
import android.widget.Button;
import android.widget.LinearLayout;

public class HelloLayout extends Activity {
	
	private final static int cmdId = 100 ;
	private HelloLayout self ;
	
	@Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        requestWindowFeature(Window.FEATURE_NO_TITLE);
        setContentView(R.layout.layouttest);
        
        self = this ;
        
        // _initButtonLayout() ;
        
        Button setButton = (Button)findViewById(R.id.layoutSettingButton) ;
        setButton.setOnClickListener(new OnClickListener() {
			@Override
			public void onClick(View v) {
				Intent intent = new Intent(self, HelloLayoutSetting.class);
				// startActivity(intent);
				startActivityForResult(intent, cmdId) ;
			}
		}) ;
        
    }
	
	@Override
	protected void onResume() {
		super.onResume();
		_initButtonLayout() ;
	}
	
	@Override
	protected void onActivityResult(int requestCode, int resultCode, Intent data) {
		
		if (requestCode == cmdId && resultCode == RESULT_OK) {
			return ;
		}
		
		super.onActivityResult(requestCode, resultCode, data);
	}
	
	protected final void _initButtonLayout() {
        HelloLayoutSettingData.SettingData data = null ;
        
        Button button1 = (Button)findViewById(R.id.tButton1) ;
        data = HelloLayoutSettingData.GetData(0) ;
        button1.setLayoutParams(new LinearLayout.LayoutParams(data.type, ViewGroup.LayoutParams.WRAP_CONTENT, data.weight)) ;
        
        Button button2 = (Button)findViewById(R.id.tButton2) ;
        data = HelloLayoutSettingData.GetData(1) ;
        button2.setLayoutParams(new LinearLayout.LayoutParams(data.type, ViewGroup.LayoutParams.WRAP_CONTENT, data.weight)) ;
        
        Button button3 = (Button)findViewById(R.id.tButton3) ;
        data = HelloLayoutSettingData.GetData(2) ;
        button3.setLayoutParams(new LinearLayout.LayoutParams(data.type, ViewGroup.LayoutParams.WRAP_CONTENT, data.weight)) ;
        
        Button button4 = (Button)findViewById(R.id.tButton4) ;
        data = HelloLayoutSettingData.GetData(3) ;
        button4.setLayoutParams(new LinearLayout.LayoutParams(data.type, ViewGroup.LayoutParams.WRAP_CONTENT, data.weight)) ;
	}
}
